package com.lemon.smartsafetynew.net.services;

import android.content.Context;
import android.util.Log;

import com.lemon.android.http.LemonRequestParams;
import com.lemon.smartsafety.app.Constants;
import com.lemon.smartsafety.app.IApplication;
import com.lemon.smartsafety.app.RefreshType;
import com.lemon.smartsafety.http.UrlInfo;
import com.lemon.smartsafety.http.callback.HandlerCallback;
import com.lemon.smartsafety.http.service.BaseHttpServices;
import com.lemon.smartsafetynew.entity.electrical.ElectricalCompanyVo;
import com.lemon.smartsafetynew.entity.electrical.ElectricalItemVo;
import com.lemon.smartsafetynew.entity.electrical.ElectricalKeyVo;
import com.lemon.smartsafetynew.entity.electrical.ElectricialRealTimeVo;
import com.lemon.smartsafetynew.entity.electrical.ElectricialSensorVo;
import com.lemon.smartsafetynew.util.constants.KeyConstants;
import com.zhy.http.okhttp.OkHttpUtils;

import java.util.List;

/**
 * Created by Andrew on 2018/3/12.
 */

public class ElectricalServices extends BaseHttpServices {

    public static final String TAG = "ElectricalServices";

    public ElectricalServices(Context context) {
        super(context);
    }

    /**
     * 初始化，等同使用构造函数
     *
     * @return
     */
    public static ElectricalServices init() {
        return new ElectricalServices(IApplication.context());
    }


    /**
     * 初始化，等同使用构造函数
     *
     * @param context
     * @return
     */
    public static ElectricalServices init(Context context) {
        return new ElectricalServices(context);
    }


    /**
     * 获得监测点列表
     */
    public void getMonitorPointList(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<ElectricalItemVo>> callback = new HandlerCallback<List<ElectricalItemVo>>(KeyConstants.URL_ELECTRICAL_POINTS_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.ELECTRICAL_POINTS_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);

    }



    /**
     * 获得企业列表
     */
    public void getMonitorCompanyList(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<ElectricalCompanyVo>> callback = new HandlerCallback<List<ElectricalCompanyVo>>(KeyConstants.URL_ELECTRICAL_COMPANY_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.ELECTRICAL_COMPANY_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);

    }


   /* *//**
     * 获得监测点列表
     *//*
    public void getElectricalRealTimeValue(LemonRequestParams params) {

        HandlerCallback<List<ElectricialRealTimeVo>> callback = new HandlerCallback<List<ElectricialRealTimeVo>>(KeyConstants.URL_ELECTRICAL_SENSOR_LIST) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.ELECTRICAL_SENSOR_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);

    }*/

    /**
     * 获得传感器图标详细
     */
    public void getElectricalChartValue(LemonRequestParams params) {

        //TODO
        HandlerCallback<ElectricialSensorVo> callback = new HandlerCallback<ElectricialSensorVo>(KeyConstants.URL_ELECTRICAL_SENSOR_CHART) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.ELECTRICAL_SENSOR_CHART, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);

    }

    public void getElectricalRealTimeValue(LemonRequestParams params) {
        HandlerCallback<ElectricialRealTimeVo> callback = new HandlerCallback<ElectricialRealTimeVo>(KeyConstants.URL_ELECTRICAL_REAL_TIME_VALUE) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.ELECTRICAL_REAL_TIME_VALUE, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);

    }

    public void getElectricalRealTimeKey(LemonRequestParams params) {
        HandlerCallback<List<ElectricalKeyVo>> callback = new HandlerCallback<List<ElectricalKeyVo>>(KeyConstants.URL_ELECTRICAL_REAL_TIME_KEY) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.ELECTRICAL_REAL_TIME_KEY, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);
    }
}
